#define NDEBUG

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>

#define NV(v)#v<<" : "<<(v)
#ifdef NDEBUG
    #define DEBUG(code)
#else
    #define DEBUG(code){code}
#endif

using ull = unsigned long long;
const size_t max_n = 150+5;
struct Point{
    ull x,y;
};
ull n;
Point points[max_n];
std::string s;
double mtx_len[max_n][max_n];
double max_len[max_n];
const double double_max = std::numeric_limits<double>::max(), double_min = std::numeric_limits<double>::min();
double min_ans {double_max}, default_ans{0};

double len(const Point &p1, const Point &p2){
    return std::sqrt(
        std::pow((double)p1.x-(double)p2.x, (double)2)+
        std::pow((double)p1.y-(double)p2.y,(double)2)
    );
}

int main(){
    // std::cout<<INF<<'\n';
    std::cin>>n;

    for(ull i = 1;i<=n;i++){
        std::cin>>points[i].x>>points[i].y;
    }

    for(ull i=1;i<=n;i++){
        std::cin>>s;
        for(ull j=1;j<=n;j++){
            if(i==j){
                continue;
            }
            if(s[j-1]=='1'){
                mtx_len[i][j] = len(points[i],points[j]);
            }else{
                mtx_len[i][j] = double_max;
            }
        }
    }
    for(ull k=1;k<=n;k++){
        for(ull i=1;i<=n;i++){
            for(ull j=1;j<=n;j++){
                double new_len;
                if(mtx_len[i][k]!=double_max && mtx_len[k][j]!=double_max){
                    new_len = mtx_len[i][k]+mtx_len[k][j];
                }else{
                    continue;
                }
                if(new_len<mtx_len[i][j]){
                    mtx_len[i][j] = new_len;
                }
                
            }
        }
    }

    for(ull i=1;i<=n;i++){
        max_len[i]=double_max;
        for(ull j=1;j<=n;j++){
            if(mtx_len[i][j]==double_max)continue;
            max_len[i] = std::max(mtx_len[i][j],(max_len[i]==double_max?double_min:max_len[i]));
            default_ans = std::max(default_ans,max_len[i]); 
        }
    }
    DEBUG(
        std::cout<<NV(min_ans)<<"\n---start\n";
    )
    for(ull i=1;i<=n;i++){
        for(ull j=i+1;j<=n;j++){
            if(mtx_len[i][j]==double_max){
                DEBUG(
                    std::cout<<NV(i)<<'\n'<<NV(j)<<'\n'<<NV(max_len[i])<<'\n'<<NV(max_len[j])<<'\n'
                        <<NV(len(points[i], points[j]))<<'\n'<<NV(max_len[i]+ len(points[i], points[j]) + max_len[j])<<'\n';
                )
                min_ans = std::min(max_len[i]+ len(points[i], points[j]) +max_len[j],min_ans);
                DEBUG(
                    std::cout<<NV(min_ans)<<'\n';
                    std::cout<<"---\n";
                )
            }
        }
    }

    std::cout<<std::fixed<<std::setprecision(6)<<(min_ans==double_max?default_ans:std::max(default_ans, min_ans))<<'\n';
}